package com.fzu.ess.sys.controller;

import com.fzu.ess.common.Model.JsonModel;
import com.fzu.ess.sys.entity.User;
import com.fzu.ess.sys.service.MessageService;
import com.fzu.ess.sys.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by ercha on 2015/10/16.
 */
@Controller
@RequestMapping(value="/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @RequestMapping(value="/index", method=RequestMethod.GET)
    public String indexPage(){
        return "/jsp/common/message/index.jsp";
    }

    @ResponseBody
    @RequestMapping(value = "/pageData", method = RequestMethod.GET)
    public JsonModel getPageData(@RequestParam(value = "page") Integer pageNumber, @RequestParam Integer pageSize,
                                 @RequestParam(required = false) String filter){
        return messageService.getDataByPage(pageNumber, pageSize, filter);
    }

    @ResponseBody
    @RequestMapping(value = "/setStatus", method = RequestMethod.POST)
    public JsonModel setStatus(String id){
        return messageService.setStatus(id);
    }
}
